<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>产前孕检首页</title>
		<link href="../css/newIndex.css" rel="stylesheet" />
		<link href="../css/myPage.css" rel="stylesheet" />
	</head>
	<body>
		<div class="bigDiv">
			<div class="allContext">
				<div class="queryInput">
					<input type="text" class="queryVal"placeholder="请输入患者姓名|就诊卡号|就诊原因"/>
					<button class="queryBtn" onclick="loadpages()">搜索</button>
				</div>
				<table class="userContTable" style="table-layout:fixed;">
					<thead>
						<tr>
							<td>序号</td>
							<td>登记编号</td>
							<td>姓名</td>
							<td>年龄</td>
							<td>初诊日期</td>
							<td>初诊孕周</td>
							<td>就诊原因</td>
							<td>穿刺日期</td>
							<td>现孕周</td>
							<td>配偶姓名</td>
							<td>诊断登记</td>
							<td>实验室结果</td>
							<td>会诊记录</td>
							<td>随访记录</td>
						</tr>
					</thead>
				</table>
				<div class="allUserTable">

					<table class="userContTable"  style="table-layout:fixed;">

						<tbody id="allDatalist">
							
						</tbody>
					</table>
				</div>
				<div class="pagingDiv">
					<div class="my-page"></div>
				</div>
			</div>

		</div>
	</body>
</html>
<script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/template.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/myPage.js " type="text/javascript" charset="utf-8"></script>
<script type="text/html" id="onedatatemplate">
	{{each data as value i}}
		<tr data-diacrisis-id={{value.diacrisisId}} data-patientcardid={{value.patientCardId}}>
			<td>{{i+1}}</td>
			<td>{{ value.recordId }}</td>
			<td>{{ value.patientName }}</td>
			<td>{{ value.patientAge }}</td>
			<td>{{ value.recordTime }}</td>
			<td>{{ value.gestWeeks }}</td>
			<td><input readonly title='{{ value.diacrisisRemark }}	' style="border:0;background-color: rgba(0,0,0,0);font-size:16px;color: #909090;" value='{{ value.diacrisisRemark }}'/></td>
			<td>{{ value.inspectionTime }}</td>
			<td>{{ value.weeks }}</td>
			<td>{{ value.spouseName }}</td>
			<td onclick="tozdxxgl(this)">
				{{if value.diacrisisStatus==0 }}
					<img src="../img/NewIndeximg/db.png" style="border-radius: 20px;background-color: #FFFFFF;"/>
				{{else if value.diacrisisStatus==1 }}
					<img src="../img/NewIndeximg/yellow.png"/>
				{{else if value.diacrisisStatus==2 }}
					<img src="../img/NewIndeximg/tg.png"/>
				{{/if}}
			</td>
			<td onclick="tosysjg(this)">
<!--				{{if value.diagnosisStatus==0 }}-->
<!--					<img src="../img/NewIndeximg/db.png" style="border-radius: 20px;background-color: #FFFFFF;"/>-->
<!--				{{else if value.diagnosisStatus==1 }}-->
<!--					<img src="../img/NewIndeximg/yellow.png"/>-->
<!--				{{else if value.diagnosisStatus==2 }}-->
<!--					<img src="../img/NewIndeximg/tg.png"/>-->
<!--				{{/if}}-->
								{{if value.diagnosisStatus==0 }}
									<button style="width: 32px;height: 32px;border-radius: 20px;border: 1px solid #e6e6e6;font-size: 22px;color: #fff;background: red;">!</button>
								{{else if value.diagnosisStatus==2 }}
									<button style="width: 32px;height: 32px;border-radius: 20px;border: 1px solid #e6e6e6;font-size: 22px;color: #fff;background: #ffc0cb;">!</button>
								{{else if value.diagnosisStatus==3 }}
									<button style="width: 32px;height: 32px;border-radius: 20px;border: 1px solid #e6e6e6;font-size: 22px;color: #fff;background: #ffa604;">!</button>
								{{else if value.diagnosisStatus==4 }}
								<button style="width: 32px;height: 32px;border-radius: 20px;border: 1px solid #e6e6e6;font-size: 22px;color: #ffffff;background: #4886c5;">!</button>
								{{else if value.diagnosisStatus==5 }}
									<img src="../img/NewIndeximg/tg.png"/>
								{{/if}}
			</td>
			<td onclick="tohzjl(this)">
				{{if value.dibStatus==0 }}
					<img src="../img/NewIndeximg/db.png" style="border-radius: 20px;background-color: #FFFFFF;"/>
				{{else if value.dibStatus==1 }}
					<img src="../img/NewIndeximg/yellow.png"/>
				{{else if value.dibStatus==2 }}
					<img src="../img/NewIndeximg/tg.png"/>
				{{/if}}
			</td>
			<td onclick="tosfjl(this)">
				{{if value.flupStatus==0 }}
					<img src="../img/NewIndeximg/db.png" style="border-radius: 20px;background-color: #FFFFFF;"/>
				{{else if value.flupStatus==1 }}
					<img src="../img/NewIndeximg/yellow.png"/>
				{{else if value.flupStatus==2 }}
					<img src="../img/NewIndeximg/tg.png"/>
				{{/if}}
			</td>
		</tr>
	{{/each}}
</script>
<script type="text/javascript">
	loadpages();
	var inputVal="";
	function loadpages(){
		inputVal = document.getElementsByClassName('queryVal')[0].value || null
		var xhr = new XMLHttpRequest();
		xhr.open('get', "/cqzd/do/process/list?inputVal="+inputVal, false);
		xhr.onreadystatechange = function() {
			var list = JSON.parse(xhr.responseText);
			var pages=Math.ceil(list.total/10)||1;
			myPageInit({
				pages: pages,
				currentPage: 1,
				element: '.my-page',
				callback: function(page) {
					querData(inputVal, page-1)
				}
			});
		}
		xhr.send()
	}
	function querData(condition, pageIndex) {
		var xhr = new XMLHttpRequest();
		xhr.open('get', "/cqzd/do/process/list?inputVal="+condition+"&pageIndex="+pageIndex, false);
		xhr.onreadystatechange = function() {
			var list = JSON.parse(xhr.responseText);
			LoadTableList(list.data)
		}
		xhr.send()
	}
	
	function LoadTableList(data) {
		// var nodetr = document.getElementById('allDatalist')
		// while (nodetr.hasChildNodes()) {
		// 	nodetr.removeChild(nodetr.firstChild)
		// }
		$('#allDatalist').children().remove()
		if (data) {
			var htmlNode = template('onedatatemplate', {"data":data});
			document.getElementById('allDatalist').innerHTML = document.getElementById('allDatalist').innerHTML + htmlNode;
		}
	}

	function tozdxxgl(_this){
		window.open('/static/cqzd/pages/NewZDXXGL.html?id='+_this.parentElement.dataset.diacrisisId)
	}
	function tosysjg(_this){
		window.open('/static/cqzd/pages/ZDJGGL.html?id='+_this.parentElement.dataset.diacrisisId)
	}
	function tohzjl(_this){
		window.open('/static/cqzd/pages/HZXXGL.html?patientCardId='+_this.parentElement.dataset.patientcardid)
	}
	function tosfjl(_this){
		window.open('/static/cqzd/page/flup/SFXXGL.html?patientCardId='+_this.parentElement.dataset.patientcardid)
	}



</script>
